package com.zhang.spring.boot.mongo;

public enum PredicateEnum {

    Is("Is","$eq"),
    Equals("Equals","$eq"),
    Like("Like"," like '%' || ? || '%' "),
    IsNull("IsNull"," is null "),
    Between("Between"," between ? and ? " );


    private String predicate;
    private String expression;

    private PredicateEnum(String predicate, String expression){
        this.predicate=predicate;
        this.expression=expression;
    }

    public String getPredicate() {
        return predicate;
    }

    public String getExpression() {
        return expression;
    }

    public static PredicateEnum getEnumByCode(String code){
        if(code == null){
            return Is;
        }
        for(PredicateEnum temp:PredicateEnum.values()){
            if(temp.getPredicate().equals(code)){
                return temp;
            }
        }
        return Is;
    }
}
